package d01_Arrays;

import java.util.Arrays;
import java.util.Comparator;
import java.util.function.IntToDoubleFunction;

public class Test01 {
    public static void main(String[] args) {
        //返回数组的内容
        int[] arr01={11,55,88,99,3,44,75};
        String res1=Arrays.toString(arr01);
        System.out.println(res1);
        //拷贝数据、扩容
       int[] arr02= Arrays.copyOfRange(arr01,1,5);
        System.out.println(Arrays.toString(arr02));
        int[] arr03=Arrays.copyOf(arr01,10);
        System.out.println(Arrays.toString(arr03));
        double[] score={44.2,22.2,78.21,45.91,52.36,45.63};
        //给score数据中的数据都加10
        Arrays.setAll(score, new IntToDoubleFunction() {
            @Override
            public double applyAsDouble(int value) {
                return score[value]+10;
            }
        });
        Arrays.sort(score);
        System.out.println(Arrays.toString(score));
    //对象排序
        Student[] s=new Student[4];
        s[0]=new Student("李一",168,21);
        s[1]=new Student("李二",158,24);
        s[2]=new Student("李三",170,20);
        s[3]=new Student("李四",185,19);
//        Arrays.sort(s);//报错，
//        System.out.println(Arrays.toString(s));
        //自定义排序规则一：
        Arrays.sort(s);
        System.out.println(Arrays.toString(s));;
        Arrays.sort(s, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge()-o1.getAge();
            }
        });
        System.out.println(Arrays.toString(s));



    }
}
